class CompaniasController < ApplicationController
  # GET /companias
  # GET /companias.xml
  def index
    @companias = Compania.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @companias }
    end
  end

  # GET /companias/1
  # GET /companias/1.xml
  def show
    @compania = Compania.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @compania }
    end
  end

  # GET /companias/new
  # GET /companias/new.xml
  def new
    @compania = Compania.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @compania }
    end
  end

  # GET /companias/1/edit
  def edit
    @compania = Compania.find(params[:id])
  end

  # POST /companias
  # POST /companias.xml
  def create
    @compania = Compania.new(params[:compania])

    respond_to do |format|
      if @compania.save
        flash[:notice] = 'Compania was successfully created.'
        format.html { redirect_to(@compania) }
        format.xml  { render :xml => @compania, :status => :created, :location => @compania }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @compania.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /companias/1
  # PUT /companias/1.xml
  def update
    @compania = Compania.find(params[:id])

    respond_to do |format|
      if @compania.update_attributes(params[:compania])
        flash[:notice] = 'Compania was successfully updated.'
        format.html { redirect_to(@compania) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @compania.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /companias/1
  # DELETE /companias/1.xml
  def destroy
    @compania = Compania.find(params[:id])
    @compania.destroy

    respond_to do |format|
      format.html { redirect_to(companias_url) }
      format.xml  { head :ok }
    end
  end
end
